package com.lineage.server.command.executor;

import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.world.World;
import java.util.Iterator;
import java.util.logging.Logger;

public class L1Save implements L1CommandExecutor {
  private static Logger _log = Logger.getLogger(L1Save.class.getName());
  
  public static L1CommandExecutor getInstance() {
    return new L1Save();
  }
  
  public void execute(L1PcInstance paramL1PcInstance, String paramString1, String paramString2) {
    try {
      Iterator<L1PcInstance> iterator = World.get().getAllPlayers().iterator();
      while (iterator.hasNext()) {
        L1PcInstance localL1PcInstance = iterator.next();
        localL1PcInstance.save();
        localL1PcInstance.saveInventory();
        localL1PcInstance.sendPackets((ServerBasePacket)new S_SystemMessage("您的资料已经受到储存保护。"));
        paramL1PcInstance.sendPackets((ServerBasePacket)new S_SystemMessage("伺服器资料储存完毕。"));
        System.out.println(
            "伺服器上的人物资料已储存到资料库中。 剩余记忆体:" + (Runtime.getRuntime().freeMemory() / 1024L / 1024L) + "MB");
      } 
    } catch (Exception exception) {}
  }
}
